<?php
include('../../inc/global.inc');
include("../islogin.php");
$url="index.php";
$thepage=$_GET['page']?$_GET['page']:1;
$maxpage=20;
if($_GET['del_act']){
mysql_query("delete from adwords where id='".$_GET['del_id']."'");
echo "<script>location='index.php';</script>";
}
?>
<HTML>
<HEAD>
<TITLE>Admin</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<LINK href="../css/css.css" rel=stylesheet>
</HEAD>
<BODY>
<center>
  <table width="95%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td height="25" bgcolor="#EEEEF9" style="padding-left:5px;">广告管理系统 &nbsp;&nbsp;<a href="javascript:history.go(-1)">返回</a></td>
    </tr>
  </table>
  <table width="95%" border="0" cellspacing="0" cellpadding="0">
    <form method="get" action="">
      <tr>
        <td height="25"><font color="#0000FF">搜索：</font>
            <input name="s_name" type="text" size="20">
            &nbsp;
            <input name="submit" type="submit" value="搜索"></td>
      </tr>
    </form>
  </table>
  <table width="95%" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
    <tr>
      <td width="5%" height="30" align="center" bgcolor="#8DA8CF">编号</td>
      <td width="18%" align="center" bgcolor="#8DA8CF">会员账号[ID]</td>
      <td width="6%" align="center" bgcolor="#8DA8CF">类型</td>
      <td width="12%" align="center" bgcolor="#8DA8CF">开始时间</td>
      <td width="12%" align="center" bgcolor="#8DA8CF">结束时间</td>
      <td width="30%" align="center" bgcolor="#8DA8CF">备注</td>
      <td width="5%" align="center" bgcolor="#8DA8CF">状态</td>
      <td width="12%" align="center" bgcolor="#8DA8CF"><a href="index_modify.php?tj=ok">添加广告</a></td>
    </tr>
<?php
if($_GET[s_name]){
$sqls=" and ad_shuoming like '%$_GET[s_name]%'";
}

$sql="select * from adwords where 1=1 ".$sqls." order by ad_endtime asc,id desc";
$rs=mysql_query($sql);
$i=1;
while($row=mysql_fetch_array($rs)){
$color=($i%2)?"#FFFFFF":"#eeeeee";
?>
    <tr bgcolor=<?=$color?>>
      <td height="25" align="center"><?=$i?></td>
	  <td align="center">
	  <?php if($row[member_id]){
	        $rs2=@mysql_query("select m_user from member where id='".$row['member_id']."'");
	        $row2=@mysql_fetch_array($rs2);
			echo $row2[m_user];}?>[<?=$row[member_id]?>]</td>
      <td align="center"><?=$row[type_id]?></td>
      <td align="center"><?=date("Y-m-d",strtotime($row[ad_addtime]))?></td>
      <td align="center"><?php if($row[ad_endtime]<date("Y-m-d")){?><font color="#FF0000"><?=date("Y-m-d",strtotime($row[ad_endtime]))?></font><?php }else{?><?=date("Y-m-d",strtotime($row[ad_endtime]))?><?php }?></td>
      <td align="center"><?=$row[ad_shuoming]?></td>
      <td align="center"><?php if($row[is_ok]==1){echo "是";}else{echo "<font color='red'>否</font>";}?></td>
      <td align="center"><a href="index_modify.php?xg=ok&xg_id=<?=$row['id']?>">编辑</a>&nbsp;&nbsp;|&nbsp;&nbsp;<a href="index.php?del_act=ok&del_id=<?=$row['id']?>" onClick="return del()">删除</a></td>
    </tr>
<?php
$i++;
}
$totalrecord=mysql_result(mysql_query("select count(id) from adwords where 1=1".$sqls),0);
$totalpage=ceil($totalrecord/$maxpage);
?>
    <tr><form method="get" action="<?=$url?>?s_name=<?=$_GET[s_name]?>">
       <td height="31" colspan="8" align="center" bgcolor="#FFFFFF">
	   <?php if($thepage>1){?>
	   <a href="<?=$url?>?s_name=<?=$_GET[s_name]?>">第一页</a>&nbsp;<a href="<?=$url?>?page=<?=$thepage-1?>&s_name=<?=$_GET[s_name]?>">上一页</a>
	   <?php }?>
	   <?php if($thepage!=$totalpage&&$totalpage>1){?>
	   <a href="<?=$url?>?page=<?=$thepage+1?>&s_name=<?=$_GET[s_name]?>">下一页</a>&nbsp;<a href="<?=$url?>?page=<?=$totalpage?>&s_name=<?=$_GET[s_name]?>">最后一页</a>
      <?php }?>【共<font color="red"><?=$totalrecord?></font>条记录】【每页<font color="red"><?=$maxpage?></font>条记录】【共<font color="red"><?=$totalpage?></font>页】      </td></form>
	</tr>
  </table>
<div style="width:95%; color:#FF0000;" align="left">注：1、热点产品广告，2、产品栏目列表广告（横幅）3、产品栏目列表广告（竖幅）</div>
</center>
</BODY>
</HTML>
